// TF_KB.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "TF_KB_FW.h"
#include <Windows.h>
//#include "ecutil.h"

void usage(void)
{
	fprintf(stderr, "Usage: tf_kb.exe -c <color code> | -v");
	fprintf(stderr, "\nOption");
	fprintf(stderr, "\n\tc	color, 1(W),2(R),3(G),4(B),5(W),6(P)...");
	fprintf(stderr, "\n\tv	show KB Firmware version");
	fprintf(stderr, "\nReturn code");
	fprintf(stderr, "\n\t0	Pass\n\t1	Fail");
	exit(1);
}

int main(int argc, char* argv[])
{
	int iVer = 0;
	int mode = 1;
	int ret = 0;

	if ( argc == 1 )	usage();
	if ( argc == 2 && strcmp(argv[1],"/?")==0 )	usage();

	if (argc == 2 && strcmp(argv[1],"-v") == 0){
		if(InitUSBHid())
			if(!GetFirmwareVersion())
				ret=1;
	}else if(argc==3 && strcmp(argv[1],"-c") == 0 ){
		mode = atoi(argv[2]);
		if (InitUSBHid()){
			switch(mode){
				case 1:
					SetColor(0xff, 0xff, 0xff);  //white
					printf("\nColor: White");
					break;
				case 2:
					SetColor(0xff, 0x0, 0x0); //red
					printf("\nColor: Red");
					break;
				case 3:
					SetColor(0x0, 0xff, 0x0); //green
					printf("\nColor: Green");
					break;
				case 4:
					SetColor(0x0, 0x0, 0xff);//blue
					printf("\nColor: Blue");
					break;
				case 5:
					SetColor(0xff, 0x0, 0xff);//Purple
					printf("\nColor: Purple");
					break;
				case 6:
					SetColor(0x0, 0xff, 0xff); //Water blue
					printf("\nColor: Light Green");
					break;
				case 7:
					SetColor(0xf1, 0x5a, 0x24); // Low Red???
					printf("\nColor: Pink");
					break;
				case 8:
					SetColor(0xf7, 0x93, 0x1e); //Orange
					printf("\nColor: Rose Red");
					break;
				case 9:
					SetColorFourZone(9, 0xff, 0, 0);
					SetColorFourZone(10, 0, 0xff, 0);
					SetColorFourZone(11, 0, 0, 0xff);
					SetColorFourZone(12, 0xff, 0, 0xff);
					printf("\nColor: Four zone rainbow");
					break;
				default:
					printf("\nColor: Unknown");
					ret=1;
					break;
			}
		}
		printf("\nRetrun code: %d\n", ret);
		return ret;
	}else{
		usage();
	}

	return ret;
}

